#ifndef MOCHA_DETAIL_IMAGE_PLUGIN_HPP_INCLUDED
#define MOCHA_DETAIL_IMAGE_PLUGIN_HPP_INCLUDED

/**
 * @file 
 */

#include <cstdint>
#include <boost/filesystem.hpp>
#include <boost/noncopyable.hpp>
#include "mocha/color.hpp"
#include "mocha/enum_string.hpp"
#include "mocha/image_plugin.h"
#include "mocha/interface_language.hpp"
#include "mocha/plugin.hpp"
#include "mocha/region.hpp"

namespace mocha { namespace graphics {
using ::mocha_image_file_format_mask;
using ::mocha_image_file_format_bmp;
using ::mocha_image_file_format_gif;
using ::mocha_image_file_format_jpeg;
using ::mocha_image_file_format_mng;
using ::mocha_image_file_format_png;
using ::mocha_image_file_format_tiff;
using ::mocha_c_image_plugin;
typedef mocha_image_file_format_mask image_file_format_mask;
typedef mocha_c_image_plugin c_image_plugin;
/**
 * 
 */
class image_plugin : public plugin, public boost::noncopyable {
public:
	virtual std::int32_t load(const boost::filesystem::path& file) = 0;
	virtual std::int32_t load(std::int8_t* buffer, std::uint32_t size) = 0;
	virtual std::int32_t load(std::int8_t* buffer, std::uint32_t width, std::uint32_t height, const pixel_format& format) = 0;
	virtual void free() = 0;
	virtual std::int32_t crop(const region<std::int32_t>& region) = 0;
	virtual std::int32_t scale(std::uint32_t width, std::uint32_t height) = 0;
	virtual std::int32_t convert(const pixel_format& format) = 0;
	virtual void pixels(std::int8_t*& buffer, std::uint32_t* size) = 0;
	virtual void pixels(std::int8_t const *& buffer, std::uint32_t* size) const = 0;
	virtual std::int32_t format(pixel_format& format) const = 0;
	virtual std::uint32_t width() const = 0;
	virtual std::uint32_t height() const = 0;
	virtual std::int8_t loaded() const = 0;
};
}
template<>
struct interface_language<mocha::graphics::c_image_plugin> {
	enum { language = mocha_plugin_language_c };
};
template<>
struct interface_language<mocha::graphics::image_plugin> {
	enum { language = mocha_plugin_language_cpp };
};
}
MOCHA_ENUM_STRING_BEGIN(mocha::graphics::image_file_format_mask) {
	MOCHA_ENUM_STRING(mocha_image_file_format_bmp);
	MOCHA_ENUM_STRING(mocha_image_file_format_gif);
	MOCHA_ENUM_STRING(mocha_image_file_format_jpeg);
	MOCHA_ENUM_STRING(mocha_image_file_format_mng);
	MOCHA_ENUM_STRING(mocha_image_file_format_png);
	MOCHA_ENUM_STRING(mocha_image_file_format_tiff);
	MOCHA_ENUM_ALIAS(mocha_image_file_format_bmp, "bmp");
	MOCHA_ENUM_ALIAS(mocha_image_file_format_gif, "gif");
	MOCHA_ENUM_ALIAS(mocha_image_file_format_jpeg, "jpeg");
	MOCHA_ENUM_ALIAS(mocha_image_file_format_jpeg, "mng");
	MOCHA_ENUM_ALIAS(mocha_image_file_format_jpeg, "png");
	MOCHA_ENUM_ALIAS(mocha_image_file_format_jpeg, "tiff");
} MOCHA_ENUM_STRING_END;

#endif

